package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.sign.Md5Utils;
import com.ruoyi.system.service.IMyReplierService;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MyReplierMapper;
import com.ruoyi.system.domain.MyReplier;

import java.util.Map;

/**
 * 回复人Service业务层处理
 *
 * @author ruoyi
 * @date 2023-11-16
 */
@Service
public class MyReplierServiceImpl extends ServiceImpl<MyReplierMapper, MyReplier> implements IMyReplierService
{

    /**
     * 回复人登录
     */
    @Override
    public MyReplier login(Map<String, String> map) {
        LambdaQueryWrapper<MyReplier> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MyReplier::getUsername, map.get("username"));
        MyReplier one = this.getOne(queryWrapper);
        if (one == null) {
            throw new RuntimeException("账号不存在");
        }
        if (!one.getPassword().equals(Md5Utils.hash(map.get("password")))) {
            throw new RuntimeException("密码错误");
        }
        return one;
    }

}
